Skip to content

Conversation

@zzak
Copy link

@zzak zzak commented Oct 16, 2025

See: rails/rails@7d12071

This change will land in Rails 8.1.

@orehmane
Copy link

Started running into this one, would be great to get it merged.

@jasonligg
Copy link

Seeing this as well. 🙏

@alexdeng-mp
Copy link

We're seeing this too. Would be awesome to get this in soon

@robertino
Copy link

robertino commented Oct 23, 2025

bumping again, this is causing errors now:
Could not log "sql.active_record" event. NoMethodError: undefined method 'sql_runtime' for module ActiveRecord::RuntimeRegistry on Rails 8.1.0 which was released yesterday

@orehmane
Copy link

I created a monkeypatch to fix this in the meantime, based on @rubyroob's excellent work in #249.

Stick this in a file in config/initializers and it should clear up issues until the gem is updated.

# frozen_string_literal: true

LAST_TESTED_VERSION = '4.18.0'

require 'rails_semantic_logger/version'

unless RailsSemanticLogger::VERSION == LAST_TESTED_VERSION
  raise "rails_semantic_logger is version #{RailsSemanticLogger::VERSION} but the monkey patch was last tested on " \
        "#{LAST_TESTED_VERSION} - manually check if it can find the sql_runtime module."
end

module RailsSemanticLogger
  module ActiveRecord
    class LogSubscriber < ActiveSupport::LogSubscriber
      def self.runtime=(value)
        if ::ActiveRecord::RuntimeRegistry.respond_to?(:stats)
          ::ActiveRecord::RuntimeRegistry.stats.sql_runtime = value
        else
          ::ActiveRecord::RuntimeRegistry.sql_runtime = value
        end
      end

      def self.runtime
        if ::ActiveRecord::RuntimeRegistry.respond_to?(:stats)
          ::ActiveRecord::RuntimeRegistry.stats.sql_runtime ||= 0
        else
          ::ActiveRecord::RuntimeRegistry.sql_runtime ||= 0
        end
      end
    end
  end
end

@yuki-yogi
Copy link

@zzak
Hello, Thank you so much for submitting this pull request! I know you must be busy, but I would really appreciate it if you could merge this when you have a free moment. Thank you for your contribution.

@rubyroobs
Copy link

I created a monkeypatch to fix this in the meantime, based on @rubyroob's excellent work in #249.

It's a shame your tag didn't work, as I started seeing this error today - thanks @orehmane !

@orehmane
Copy link

Thank you @rubyroobs! Your patch saved me earlier, just trying to pay it forward. :)

@totus
Copy link

totus commented Oct 28, 2025

@reidmorrison would it be possible to have it merged sooner rather than later given that rails 8.1 is out?

Copy link

@rud rud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails 8.1.0 is out, this looks like a neat little patch to rollout

thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 28, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 28, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 29, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 30, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 30, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 30, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 31, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
thomasleese added a commit to nhsuk/manage-vaccinations-in-schools that referenced this pull request Oct 31, 2025
This adds a patch from
reidmorrison/rails_semantic_logger#276 which we
need until support for Rails 8.1 is added officially.

Jira-Issue: MAV-2386
@ximus
Copy link

ximus commented Nov 1, 2025

@reidmorrison more and more people are going to start hitting this on rails 8.1+. This patch is important to have.

ximus added a commit to Modern-Treasury/rails_semantic_logger that referenced this pull request Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.